

<?php
if ($this->code == "0"){
    echo "<legend>";
    echo $this->msg;
    echo "</legend>";
}else echo $this->msg;

if ($this->code == ""){



?>
<legend>Pengubahan Ahli Waris</legend>
<div class="row clearfix">
<div class="col-md-6 column">
<form method="post" id="frm" name="frm">

                <!-- Member form -->

                
                <h4>Ubah Ahli Waris</h4>
        
        <!-- contact_name input-->
        <div class="form-group">
                
                <input id="contact_name" name="contact_name" type="text" placeholder="Nama Ahli Waris" required 
                class="form-control" value="<?php echo (isset($this->data["contact_name"])) ? $this->data["contact_name"] : ""; ?>">
                <input id="member_contact_id" name="member_contact_id" type="hidden" value="<?php echo (isset($this->data["member_contact_id"])) ? $this->data["member_contact_id"] : ""; ?>">
        </div>
        <!-- mobile_no input-->
        <div class="form-group">
            
                <input id="mobile_no" name="mobile_no" type="text" placeholder="No HP Ahli Waris" required
                class="form-control" value="<?php echo (isset($this->data["mobile_no"])) ? $this->data["mobile_no"] : ""; ?>">
                
        </div>
        <!-- phone input-->
        <div class="form-group">
            
                <input id="phone" name="phone" type="text" placeholder="No Tlp Ahli Waris" required
                class="form-control" value="<?php echo (isset($this->data["phone"])) ? $this->data["phone"] : ""; ?>">
                
        </div>
        <!-- email input-->
        <div class="form-group">

                <input id="email" name="email" type="text" placeholder="Email Ahli Waris" required 
                class="form-control" value="<?php echo (isset($this->data["email"])) ? $this->data["email"] : ""; ?>">

        </div>

        <!-- no_ktp input-->
        <div class="form-group">

                <input id="no_ktp" name="no_ktp" type="text" placeholder="KTP Ahli Waris" required
                class="form-control" value="<?php echo (isset($this->data["no_ktp"])) ? $this->data["no_ktp"] : ""; ?>">

        </div>
    </div>
</div>


<!-- submit btn-->
                <div class="control-group">
                    <label class="control-label"></label>
                    <div class="controls">
                        <button class="btn btn-default" type="submit" id="btnSubmit" name="btnSubmit">
                        Submit</button> <div id="div_result"></div>
                        <p class="help-block"></p>
                    </div>
                </div>
</form>



        <script>

        /* Attach a submit handler to the form */
        $("#frm").submit(function(event) {

            /* Stop form from submitting normally */
            event.preventDefault();

            /* Clear result div*/
            $("#div_result").html('');
            $("#btnSubmit").html('Memproses...');
            $("#btnSubmit").attr('disabled','disabled');

            /* Get some values from elements on the page: */
            var values = $(this).serialize();

            var msg = [];

            /* Send the data using post and put the results in a div */

            $.ajax({
                url: "ahliwaris/",
                type: "post",
                data: values,
                success: function(response, opts){
                    var cekSess = response.toUpperCase().search("SESSION TIMEOUT");

                    if (cekSess < 0){
                        var cekStatus = response.toUpperCase().search("ERROR");

                        if (cekStatus < 0){
                            $("#div_content").html(response);
                        }else{

                            var resp = response.replace('ERROR', '');

                            msg.push('<span>'+resp+'</span>');
                            $.messager.alert('Info', msg.join('<br/>'));

                            //$("#div_result").html(resp);
                            $("#btnSubmit").removeAttr('disabled');
                            $("#btnSubmit").html('Submit');
                        }
                    }else{
                        location.href='<?php echo $this->baseUrl() ?>/index/login/msg/Session Timeout silahkan login kembali !';
                    }
                },
                error:function(response, opts){
                    //alert("failure");
                    //$("#div_result").html(response);
                    msg.push('<span>'+response+'</span>');
                    $.messager.alert('Info', msg.join('<br/>'));

                    $("#btnSubmit").removeAttr('disabled');
                }
            });

        });

        </script>

        <?php } ?>
    